package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author bo.li
 * @Date 2023/3/16 10:49
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/channel")
@Slf4j
public class WmChannelController {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult listAll(){
       return wmChannelService.findAll();
    }
      @GetMapping("/del/{id}")
    public ResponseResult deletea(@PathVariable Integer id){
        log.info("删除频道{}",id);
       return wmChannelService.delete(id);
    }
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmChannelDto dto){
        log.info("查询频道{}",dto);
        return wmChannelService.list(dto);
    }
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel){
        log.info("新增频道{}",wmChannel);
        return wmChannelService.add(wmChannel);
    }
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel){
        log.info("修改频道{}",wmChannel);
        return wmChannelService.updata(wmChannel);
    }

}